package com.剑指offer.第七章队列;

import java.util.LinkedList;
import java.util.Queue;

public class MetaClass {

    private Queue<Integer> queue;

    private int size;

    private int sum;


    public MetaClass(int size) {
        this.size = size;
        queue = new LinkedList<>();
    }


    public double calc(int num) {
        queue.offer(num);
        sum += sum;
        if (queue.size() > size) {
            sum -= queue.poll();
        }

        return (double) sum / size;
    }

}
